<template>
  <div class="app-container">
    <el-card>
      <h4>我的收藏</h4>
      <el-table :data="collectList" style="width: 100%">
        <el-table-column prop="fullname" label="基本信息" width="300">
          <template slot-scope="scope">
             <div style="display: flex">
                  <div class="portraitImg">
                    <img
                      :src="
                        scope.row.photoImg === 0
                          ? scope.row.photoUrl
                          : 'https://blwcompany.nbblmc.cn' + scope.row.photoUrl
                      "
                      alt=""
                    />
                  </div>
                  <div style="margin-left: 10px">
                    <div>
                      <div style="color: #409eff">{{ scope.row.fullname }}</div>
                    </div>
                    <div>
                      {{ scope.row.age }}岁 | {{ scope.row.educationText }} |
                      {{ scope.row.experienceText }}经验 |
                      {{ scope.row.sexText }}
                    </div>
                  </div>
                </div>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="experienceText" label="工作经验">
        </el-table-column>
        <el-table-column
          align="center"
          prop="intentionDistrict"
          label="求职地区"
        >
        </el-table-column>
        <el-table-column prop="intentionJobs" label="求职意向" width="width">
        </el-table-column>
        <el-table-column prop="experienceText" label="收藏时间" width="width">
          <template slot-scope="scope">
            {{ scope.row.addtime | dateFormat }}
          </template>
        </el-table-column>
        <el-table-column prop="prop" label="操作" width="width">
          <template slot-scope="scope">
            <el-button
              type="danger"
              size="small"
              @click="delClick(scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-row :gutter="10" style="margin-top: 20px" type="flex" justify="end">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[10, 20, 30, 50]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import {
  ResumeCollectionListApi,
  ResumeCollectionApi,
} from "@/api/Resume_Management";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      collectQuery: {
        page: 1,
        pagesize: 10,
        uid: "",
      },
      collectList: [],
      total: "",
    };
  },
  computed: {
    ...mapGetters(["userId"]),
  },
  created() {
    this.collectQuery.uid = this.userId;
    this.ResumeCollectionList();
  },
  methods: {
    // 收藏列表
    async ResumeCollectionList() {
      const res = await ResumeCollectionListApi(this.collectQuery);
      this.collectList = res.records;
      this.total = res.total;
    },
    // 选中页码数量改变时候
    handleSizeChange(val) {
      this.collectQuery.pagesize = val;
      this.ResumeCollectionList();
    },
    // 点击页码改变时候
    handleCurrentChange(val) {
      this.collectQuery.page = val;
      this.ResumeCollectionList();
    },
    // 删除
    async delClick(id) {
      console.log(id);
      this.$confirm("确定要删除该数据吗？, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          try {
            const res = await ResumeCollectionApi(id);
            if (res.code === 1) {
              this.$message.success("删除成功!");
              this.ResumeCollectionList();
            } else {
              this.$message.error("删除失败!");
            }
          } catch {
            this.$message.error("删除失败!");
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.portraitImg {
  img {
    border-radius: 50%;
    width: 52px;
    height: 52px;
  }
}
</style>
